package com.itheima.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
public class SoundRedisJob {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Scheduled(cron = "0 0 0 * * ?")
    // @Scheduled(cron = "0/10 * * * * ?")  测试使用
    public void deleteRedisSoundCount(){
        System.out.println("redis清除开始");
        Set<String> keys = stringRedisTemplate.keys("SOUND_*");
        for (String key : keys) {
            stringRedisTemplate.delete(key);
        }
        System.out.println("redis清除成功....");
    }
}
